package com.example.yjhvideo.controller;

import com.example.yjhuser.entity.Comment;
import com.example.yjhvideo.client.userClient;
import com.example.yjhvideo.client.userOneClient;
import com.example.yjhvideo.entity.Video;
import com.example.yjhvideo.service.VideoService;
import com.yc.yjh.entity.Result;
import com.yc.yjh.entity.Users;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/video")
public class VideoController {


    @Resource
    private VideoService videoService;

    @RequestMapping("/all")
    public Result getAllVideo(){
        final List<Video> allVideo = videoService.getAllVideo();
        return Result.success("查询成功",allVideo);
    }

    @RequestMapping("/getById")
    public Result getVideoById(@RequestParam String id){
        final Video videoById = videoService.getVideoById(id);
        return Result.success("查询成功",videoById);
    }

    @Resource
    private userClient  userClient;

    @GetMapping("/video/byId")
    public Result getAllVideoCommentById(@RequestParam("id") String id){
        String type="1";
        return Result.success("OK",userClient.getAllVideoCommentById(id));
    }

    @PostMapping("/set")
    public Result setComment(@RequestBody Comment comment){
        final Result result = userClient.setComment(comment);
        return  result;
    }
    @GetMapping("/del")
    public  Result setComment(@RequestParam("id") String id){
        final Result result = userClient.setComment(id);
        return  result;
    }

    @Resource
    private userOneClient userOneClient;
    @RequestMapping("/user")
    public Result selectOneUserByName(@RequestParam("username") String username){
        final Result result = userOneClient.selectOneUserByName(username);
        return result;
    }

}
